<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>幻灯片展示</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6">
<link rel="stylesheet" href="${pageContext.request.contextPath}/js/lightbox/baguetteBox.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/js/lightbox/gallery-clean.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/lightbox/htmleaf-demo.css">
<link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
</head>
<body>
	<div class="container gallery-container">
		<div class="tz-gallery">
			<div class="row"></div>
		</div>
	</div>
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/lightbox/baguetteBox.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript">
$(function() {
	echoAllImgInfo();
	baguetteBox.run('.tz-gallery');
});

function echoAllImgInfo() {
	$.ajax({
		url : "../slideshow/getSlideImgNames.htm",
		cache : false,
		async : false,
		type : "get",
		dataType : "json",
		beforeSend : function() {
			layer.load(0, {
				shade : false
			});
		},
		complete : function() {
			layer.closeAll("loading");
		},
		success : function(result) {
			if (result.status == 0) {
				var data = result.data;
				for (var i = 0; i < data.length; i++) {
					$('.row').append(
									'<div class="col-sm-6 col-md-4"><div class="thumbnail"><a class="lightbox" href="${pageContext.request.contextPath}/img/slideshow/'+ data[i] +'"><img src="${pageContext.request.contextPath}/img/slideshow/'+ data[i] +'" alt="' + data[i] +'"></a><div class="caption"><input type="button" class="btn btn-info" value="删除" onclick=delImg("' + data[i] + '") /></div></div></div>');
				}
				return;
			}
		}
	});
}

//删除图片
function delImg(slideImgName){
	layer.confirm('你确定要删除【' + slideImgName + '】此图片吗？', {
        btn: ['删除', '取消'] //按钮
    },function(){
    	$.ajax({
    		url : "../slideshow/delSlideImg.htm",
    		cache : false,
    		async : false,
    		type : "get",
    		dataType : "json",
    		beforeSend : function() {layer.load(0, {shade : false});},
    		complete : function() {layer.closeAll("loading");},
    		data:{"fileName":slideImgName},
    		success : function(result) {
    			if (result.status == 0) {
    				layer.msg(result.message, {time:2000,icon: 1});
    				setTimeout("location.reload()",1000);	//延迟2秒后刷新页面
    				return;
    			}else{
    				layer.msg(result.message, {icon: 2});
    			}
    		}
    	});
    },function(){});
}
</script>
</body>
</html>